import { createApp } from 'vue'
// import store from './store'
import App from './App.vue'
import router from './router'


//文档地址: https://next.antdv.com/components/overview-cn/
import Antd from 'ant-design-vue'



//全局库,变量,函数等等 为兼容以前项目开发的组件,将axios,echarts直接挂载在window上了
import wind from 'tools/index'



const app = createApp(App).use(router).use(Antd);


import * as antIcons from '@ant-design/icons-vue'
Object.keys(antIcons).forEach(key => {
	app.component(key, antIcons[key])
})
// 图标添加到全局
app.config.globalProperties.$antIcons = antIcons;



/**
 * 弹窗提示的全局配置
 * 文档地址: https://next.antdv.com/components/message-cn
 * 
 * 1.组件中提示框用法: this.$message.success(), this.$message.error(), this.$message.warn(), this.$message.info(), this.$message.loading()
 * 2.销毁: this.$message.destroy()
 * 
 * 3.组件中对话框用法: this.$success(), this.$error(), this.$confirm(), this.$info(), this.$warning()
 */
import { message } from 'ant-design-vue'
message.config({
	top: `48vh`,
	duration: 2,
	maxCount: 1
})




// 颜色选择器 vue3-colorpicker
//文档: https://aesoper101.github.io/vue3-colorpicker/?path=/story/example-introduction--page
import Vue3ColorPicker from "vue3-colorpicker"
import "vue3-colorpicker/style.css"
app.use(Vue3ColorPicker)





//所有组件信息
import { commComps, prjConfig } from 'components/index'

commComps.concat(prjConfig).forEach(firstO => firstO.children.forEach(
	secondO => secondO.children.forEach(
		comp => app.component(comp.componentName, comp.vm)
	)
))




const errWarnHandler = (err, vm, info) => {
	if (!vm) {
		console.error(err);
		return
	}
	const path = vm.path || (vm._.data && vm._.data.compPath)
	vm.$error({
		centered: true,
		maskClosable: true,
		title: "组件报错:",
		content: `"${path}", 具体错误信息查看控制台.`
	})
	console.log('\n');
	console.error(`报错的组件: "${vm.path}", 错误信息如下:`);
	console.error(err);
	console.log('\n');
}

app.config.productionTip = false;
app.config.errorHandler = errWarnHandler
// app.config.warnHandler = errWarnHandler
app.mount("#app");
